{% set KUBE_APISERVER_ADDR, KUBE_APISERVER_PORT = ansible_default_ipv4.address, 6443 %}
{% if inventory_hostname in groups['master'] %}
  {% set KUBE_APISERVER_ADDR, KUBE_APISERVER_PORT = ansible_default_ipv4.address, 6443 %}
{% else %}
  {% if ha.type | default('none') == "none" %}
    {% set KUBE_APISERVER_ADDR, KUBE_APISERVER_PORT = hostvars[groups['master'][0]].inventory_hostname, 6443 %}
  {% else %}
    {% if ha.type | default('none') == "slb" %}
      {% set KUBE_APISERVER_ADDR, KUBE_APISERVER_PORT = ha.vip, 8443 %}
    {% else %}
      {% set KUBE_APISERVER_ADDR, KUBE_APISERVER_PORT = ha.vip, 6443 %}
    {% endif %}
  {% endif %}
{% endif %}

apiVersion: v1
clusters:
- cluster:
    certificate-authority: /etc/kubernetes/pki/ca.crt
    server: https://{{ KUBE_APISERVER_ADDR }}:{{ KUBE_APISERVER_PORT }}
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kube-proxy
  name: kubernetes
current-context: kubernetes
kind: Config
preferences: {}
users:
- name: kube-proxy
  user:
    client-certificate: /etc/kubernetes/pki/kube-proxy.crt
    client-key: /etc/kubernetes/pki/kube-proxy.key
